﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KL.Store.Core.Domain;
using TN.Data;
using System.Web;
namespace KL.Store.Data
{
    public class dbXmlImport
    {
        #region Get

        public static XmlImport Get(short XmlId)
        {
            IList<XmlImport> objectList = new List<XmlImport>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImport_Get", objectList, new object[] { XmlId });
            return objectList.FirstOrDefault();
        }

        #endregion

        #region GetList

        public static IList<XmlImport> GetList()
        {
            IList<XmlImport> objectList = new List<XmlImport>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImport_List", objectList);

            return objectList;
        }

        #endregion

        #region GetListById

        public static IList<XmlImport> GetListById(int XmlId)
        {
            IList<XmlImport> objectList = new List<XmlImport>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XMLImport_List_ById", objectList, new object[] {XmlId});

            return objectList;
        }

        #endregion

        #region GetKey

        public static XmlImportKey GetKey(short XmlId, string Key, string Attribute)
        {
            IList<XmlImportKey> objectList = new List<XmlImportKey>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportKeys_Get", objectList, new object[] { XmlId, Key, Attribute });
            return objectList.FirstOrDefault();
        }

        #endregion

        #region GetKeyList

        public static IList<XmlImport> GetKeyList(short XmlId)
        {
            IList<XmlImport> objectList = new List<XmlImport>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportKeys_List", objectList, new object[] { XmlId });

            return objectList;
        }

        #endregion

        #region GetGroup

        public static XmlImportGroup GetGroup(short XmlId, string XmlGroup)
        {
            IList<XmlImportGroup> objectList = new List<XmlImportGroup>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportGroup_Get", objectList, new object[] { XmlId, XmlGroup });
            if (objectList.FirstOrDefault() != null)
            {
                objectList.FirstOrDefault().XmlImportGroupAdds = GetAdds(objectList.FirstOrDefault().Id);
                if (objectList.FirstOrDefault().XmlImportGroupAdds == null)
                {
                    objectList.FirstOrDefault().XmlImportGroupAdds = new List<XmlImportGroupAdd>();
                }
            }
            return objectList.FirstOrDefault();
        }

        #endregion

        #region GetAdds

        public static IList<XmlImportGroupAdd> GetAdds(int Id)
        {
            IList<XmlImportGroupAdd> objectList = new List<XmlImportGroupAdd>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportGroup_GetAdds", objectList, new object[] { Id });
            return objectList;
        }

        #endregion

        #region InsertGroup

        public static void InsertGroup(short XmlId, string XmlGroup, int GroupId, bool IsActive)
        {
            SqlHelper.ExecuteNonQuery(dbParameters.dsnStore, "SPR_ESTORE_XmlImportGroup_Insert", new object[] { XmlId, XmlGroup, GroupId, IsActive });
        }

        #endregion

        #region InsertBrand

        public static void InsertBrand(int Id, string Brand, int BrandId, bool IsActive, decimal ProfitRate)
        {
            SqlHelper.ExecuteNonQuery(dbParameters.dsnStore, "SPR_ESTORE_XmlImportBrand_Insert", new object[] { Id, Brand, BrandId, IsActive, ProfitRate });
        }

        #endregion

        #region GetGroupList

        public static IList<XmlImportGroup> GetGroupList(short XmlId)
        {
            IList<XmlImportGroup> objectList = new List<XmlImportGroup>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportGroup_List", objectList, new object[] { XmlId });

            return objectList;
        }

        #endregion

        #region GetBrand

        public static XmlImportBrand GetBrand(int Id, string Brand)
        {
            IList<XmlImportBrand> objectList = new List<XmlImportBrand>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportBrand_Get", objectList, new object[] { Id, Brand });
            return objectList.FirstOrDefault();
        }

        #endregion

        #region GetBrandList

        public static IList<XmlImportBrand> GetBrandList(int Id)
        {
            IList<XmlImportBrand> objectList = new List<XmlImportBrand>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_XmlImportBrand_List", objectList, new object[] { Id });

            return objectList;
        }

        #endregion
    }
}
